#ifndef STRETCHANIMATION_H
#define STRETCHANIMATION_H

#include <QObject>
#include <QList>
#include <QPushButton>
#include <QTimer>
#include <QPropertyAnimation>
#include <QEasingCurve>
#include <QEventLoop>
#include <widget.h>

class StretchAnimation : public QObject
{
    Q_OBJECT
public:
    explicit StretchAnimation(QWidget *parent = 0);

    enum DIRECTION{
        LEFT,
        RIGHT,
        UP,
        DOWN
    };

    QList<QPushButton *> getButtonList() const;
    void setButtonList(const QList<QPushButton *> &value);

    QWidget *getParent() const;

    bool getValid() const;

    int getGap() const;
    void setGap(int value);

    int getDuration() const;
    void setDuration(int value);

    StretchAnimation::DIRECTION getDirection() const;
    void setDirection(const DIRECTION &value);

    QSize getSize() const;
    void setSize(const QSize &value);

    int getBorderSpace() const;
    void setBorderSpace(int value);

    QEasingCurve getStretchCurve() const;
    void setStretchCurve(const QEasingCurve &value);

    QEasingCurve getOffCurve() const;
    void setOffCurve(const QEasingCurve &value);

    int getStatPos() const;
    void setStartPos(int value);

    void setStyleSheet(const QString &value);

signals:
    void finished();
public slots:
    void startAnimation();
    void closeAnimation(QPushButton*btn);
    void showNormal();
    void test();
    void buttonClicked();
private:
    void resetFramePos();

    void loops(QPropertyAnimation * animation);

    Widget * widget;
    QWidget * parent;
    QList<QPushButton*> buttonList;
    QList<QPoint> pointList;
    bool valid = false;
    int gap;
    QSize size;
    int borderSpace;
    int duration;
    int statPos=0;
    bool isStretch = false;
    QEasingCurve stretchCurve;
    QEasingCurve offCurve;
    DIRECTION direction;
    QString styleSheet;
    bool isRunning = false;
};

#endif // STRETCHANIMATION_H
